import {
  legacyLogicalPropertiesTransformer,
  message,
  Modal,
  notification,
  type StyleProviderProps,
} from 'ant-design-vue'
const shouldUseLegacy = () => {
  const match = navigator.userAgent.match(/Chrome\/([0-9]+)/)
  if (!match) {
    return false // 如果无法匹配版本号，则不使用legacy逻辑属性
  }
  const version = match ? Number(match[1]) : 0
  console.log('version', version)
  // 这里以90作为判断的阈值
  return version < 90
}

export const styleProviderProps: StyleProviderProps = shouldUseLegacy()
  ? {
      hashPriority: 'high',
      transformers: [legacyLogicalPropertiesTransformer],
    }
  : {}
export const [modalApi, modalContextHolder] = Modal.useModal()
export const [messageApi, messageContextHolder] = message.useMessage()
export const [notificationApi, notificationContextHolder] = notification.useNotification()
